#!/bin/bash
str="abcABCabc123ABC"
str1="123456789"
#1.replace=========================

#replace like vi
echo ${str/bcA/aaa}  
#symbol '#' mears from the start of line
#like '^' in vi
echo ${str/#bcA/XXX}
echo ${str/#abc/XXX}  
#symbol '%' mears from the end of line
#like '$' in vi
echo ${str/%bcA/XXX}
echo ${str/%ABC/XXX}  

#2.substr=========================
#from the right
#get the last 3rd to the end of str
echo ${str:(-3)} 
#from the left 
#get the 3rd to the end of str
echo ${str:3} 
#from the left 
#get the 3rd to the (3+5)th of str
echo ${str:3:5} 

#3.length=========================
echo ${#str}

